package com.ling.design.impl;

import com.ling.design.ICouponDiscount;

import java.math.BigDecimal;

/**
 * @author: ling007
 * @date: 2024/9/27 15:10
 * @description:
 */

public class ZJCouponDiscount implements ICouponDiscount<Double> {

    /**
     * 直减计算
     * 1. 使⽤用商品价格减去优惠价格
     * 2. 最低⽀支付⾦金金额1元
     */
    @Override
    public BigDecimal discountAmount(Double couponInfo, BigDecimal
            skuPrice) {
        BigDecimal discountAmount = skuPrice.subtract(new
                BigDecimal(couponInfo));
        if (discountAmount.compareTo(BigDecimal.ZERO) < 1) return
                BigDecimal.ONE;
        return discountAmount;
    }
}
